package com.zjht.gmcc.servlet;

import java.io.PrintWriter;
import java.sql.PreparedStatement;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zjht.gmcc.bean.BaseServlet;

import com.zjht.gmcc.bean.util.MyJDBC;
import com.zjht.gmcc.bean.util.MySession;

public class EditMyInfo extends BaseServlet {

	private static final long serialVersionUID = -6239781617722583447L;

	public boolean process(HttpServletRequest request, HttpServletResponse response, HttpSession session, PrintWriter out, MyJDBC myJDBC, String menu)
			throws Exception {
		int i_flag = 0;

		String s_username = request.getParameter("username");
		String s_usercode = request.getParameter("usercode");
		String s_tel = request.getParameter("tel");
		String s_email = request.getParameter("email");

		PreparedStatement ps = null;

		String s_sql = "update opers set opername=?,telephone=?,email=? where opercode=?";
		ps = myJDBC.prepareStatement(s_sql);
		ps.setString(1, s_username);
		ps.setString(2, s_tel);
		ps.setString(3, s_email);
		ps.setString(4, s_usercode);

		i_flag = ps.executeUpdate();

		ps.close();
		ps = null;

		String act = "个人资料修改";
		if (i_flag > 0) {
//			Task.UpdateSMSReceiver(s_tel, request.getParameter("oldtel"), String.valueOf(MySession.getDutyid(session)),
//					MySession.getOrgcode(session), s_usercode, s_username);
			alert(out, act + "成功");
		} else {
			errAlert(request, out, menu, act + "失败");
		}
		return i_flag > 0;
	}
}
